<?php



include '/simplehtmldom/simple_html_dom.php';
set_time_limit(0);

header('connection', 'Keep-Alive');
header('accept-language', 'en-us');
header('accept-encoding', 'gzip, deflate');
header('user-agent', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)'); 

$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('connected to DB not successfully !!!' . mysql_error());
}
echo 'connected to DB successfully <br>';

$db_selected = mysql_select_db('bcc', $link);
if (!$db_selected) {
    die ('No DB available : ' . mysql_error());
}

$handle = fopen ("sugarlandfans.txt", w);
		



for($page = 1 ; $page <= 43;$page++){
	
	echo "\n ---------------------------------------------- \n" ;	
	$html = file_get_html('http://www.umgnashville.com/artist/fans/default.aspx?aid=181&pg=' . $page);


	
	foreach($html->find("div[class=allfans]") as $e){
				foreach($e->find("a[class=name]") as $a){
						$id = explode("?mid=", $a->href);
						$sql1="UPDATE chars SET datasetId='3' WHERE url='http://www.billycurrington.com/member/friends.aspx?mid=" . $id[1] . "'" ;
						$sql="UPDATE links SET datasetId='3' WHERE link_from='http://www.billycurrington.com/member/friends.aspx?mid=" . $id[1] . "'" ;
						$result = mysql_query($sql);
						$result = mysql_query($sql1);
						print_out($id[1] . "\n" ,$handle);
						$i++;
				}
	}
		
	echo $i;
	unset($html);
	unset($result);
	unset($id);
	unset($sql);
	unset($a);
	unset($e);
}

mysql_close($link);	
fclose ($handle);




function print_out($string, $handle){
	echo $string;
	fwrite ($handle, $string);
}





   
	   //$html->getElementById("imgHolder")->childNodes(1)->childNodes(1)->getAttribute('href');

?>